<?php

/*
 * Reaction - Shelter 1$*
 *
 * When you buy a Victory card, you may trash this from your hand.
 */

class Hovel extends Card implements iDarkAges, iShelter, iReactingCard, iReaction {

    public function __construct() {
        parent::__construct("Hovel", 1);
        $this->undoPlay = false;
        $this->undoBuy = false;
        
        $this->reactConditions = new ReactionConditions();
        $this->reactConditions->action = array(Buy);
        $this->reactConditions->actor = array(Yourself);
        $this->reactConditions->cardLocation = array(PlayHand);
        $this->reactConditions->limit = ForEachCard;
        $this->reactConditions->isMandatory = false;
    }

    public function getDescription() {
        return array(
            "When you buy a Victory card, you may trash this from your hand.");
    }

    public function getConditions() {
        return $this->reactConditions;
    }

    public function isReactRelevant(Game $game, $card, $name) {
        if ($card instanceof iVictory)
            return true;
        return false;
    }

    public function react(Game $game, $card, $name) {
        if ($card instanceof iVictory) {
            $options = array(new Option(1, "Yes"), new Option(2, "No"));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Trash Hovel from your hand?");
            $answer = $output[0];
            if ($answer == "Yes") {
                $hovel = $game->moveCardFromPileToPile($this, PlayHand, Trash);
                ScreenDisplay::addScreenMessage($game, true, "trash " . nicePrint($hovel) . " from your hand", "trashes " . ScreenDisplay::$LMSG . " from his hand");
            }
            $game->setTempCard($card);
        }
        return true;
    }

    public function play(Game $game, $isRealCard) {
        ScreenDisplay::addScreenMessage($game, true, "suddenly remember that ".  nicePrint($this)." does nothing", "suddenly remembers that ".  nicePrint($this)." does nothing");
        $game->cardActionFinished();
        return true;
    }

}

?>